<template>
    <view class="container backgroundlinear">
        <view class="flex main">
            <view class="content">
                <view class="content-box" >
                    <view class="card" v-for="(item,index) in categoryData">
        <!-- Content Header Satrt -->
        <!-- <template v-if="param.level !== 1">
            <view
                class="flex justify-between card--header"
                @click="goPage(`/bundle/pages/category_goods_list/index?id=${pid}`)"
            >
                <view class="name">{{ param.name }}</view>
                <view class="flex">
                    <u-icon name="arrow-right" size="22"></u-icon>
                </view>
            </view>
        </template> -->
        <view class="flex justify-between card--header" style="background-image: url('http://mzd-admin.muzhandao.com/api/uploads/image/20240911/fc7e1d4e-055e-4f7d-bb88-faa5ff4a5586.png');background-size: 100% 100%;">
            <view class="name">{{ item.name }}</view>
        </view>
        <!-- Content Header End -->

        <!-- Content Main Start -->
        <view class="card--main">
            <block >
                <view
                    class="goods flex w-[150rpx] h-[140rpx]"
                    @click="goinfo(item.id)"
                >
                    <!-- <u-image :src="item4.image" width="100%" height="100%" ></u-image> -->
                   <div>
                        <img :src="baseUrl+'api/uploads/'+item.image" class="img_sty" />
                   </div>
                    <div style="margin-left: 20rpx;width:calc(100% - 160rpx - 20rpx);display: flex;
    justify-content: space-between;
    flex-direction: column;">
                        <view class="mt-[20rpx] truncate">{{ item.name }}</view>
                        <view class="text-primary mt-[10rpx]" style="width: 100%;text-align: right;">
                            <price :price="item.price" :desc="item.unit||''"></price>
                        </view>
                    </div>
                </view>
            </block>
        </view>
        <!-- Content Main End -->
    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script lang="ts" setup>
import { apiGoodsList } from '@/api/buyOrder'
import { onLoad } from '@dcloudio/uni-app'
import Price from '@/components/price/index.vue'
import { ref } from 'vue'
const baseUrl = `${import.meta.env.VITE_APP_BASE_URL || ""}/`;

const categoryData = ref([])
onLoad(async () => {
    const res = await apiGoodsList({})
    console.log(res)
    categoryData.value = res
})
const goinfo = (id:any)=>{
    uni.navigateTo({
    url: `info?id=${id}`,
  });
}
</script>

<style lang="scss">
.container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    flex-direction: column;
    .navbar.mp_navbar {
        text {
            font-size: 24rpx !important;
            color: rgba(34, 34, 34, 0.4);
        }
    }

    .mp_navbar {
        width: 440rpx;
    }

    .h5_navbar {
        width: 610rpx;
    }

    .truncate {
        margin: 0 10rpx;
        border-radius: 16rpx;
        margin-bottom: 20rpx;
    }

    .navbar {
        height: 64rpx;
        color: #c5c5c5;
        border-radius: 60rpx;
        font-size: 28rpx;
        background-color: #f2f2f2;
    }

    .main {
        flex: 1;
        min-height: 0;
        overflow: scroll;

        ::-webkit-scrollbar {
            display: none;
        }

        .content {
            width: 100%;
            height: 100%;
            display: flex;

            .layout {
                width: 100%;
            }

            // 左侧菜单分类
            .menu {
                width: 230rpx;
                height: 100%;
                padding-top: 10rpx;
                margin-right: 20rpx;
                background: #fff;
                box-sizing: border-box;

                &--item {
                    height: 88rpx;
                    line-height: 88rpx;
                    text-align: center;
                    font-size: 26rpx;
                }
            }

            // 右侧内容
            .content-box {
                width: 100%;
                height: 100%;
                padding: 24rpx ;

                .content-box_item {
                    width: 30% !important;
                }
            }
        }
    }
}

.text-primary2 {
    color: #fff;
    // background-color: rgb(243,244,246)
    background-color: #8456ff !important;
}

.text_color_class {
    background-color: #fff !important;
}

.backgroundlinear {
    background-color: #f4f4f4 !important;
}

.u-navbar-inner,
.u-slot-content {
    align-items: normal !important;
}
.u-slot-content {
    padding-top: 10rpx;
}

@font-face {
    font-family: 'PINGFANG_SC_SEMIBOLD'; /* 你可以给字体起一个别名 */
   /*  src: url('~@/static/images/user/PINGFANG-SC-SEMIBOLD.ttf') format('truetype'); */ /* 还可以加上 ttf 格式作为备选 */
    font-weight: normal;
    font-style: normal;
} 
.card {
    margin-bottom: 20rpx;
    border-radius: 16rpx;
    padding-bottom: 20rpx;
    background-color: #fff;
    
	// color: #a998c8;
    &--header {
        color: #fff;
        padding: 13rpx 30rpx;
       
        font-size: 32rpx;

        .name {
            font-weight: 500;
            color: #fff;
            font-size: 28rpx;
        }
    }

    &--main {
        padding: 0 24rpx;
        .goods {
            padding-top: 26rpx;
            display: flex;
            width: 100%;
            min-height: 200rpx;
            .truncate{
                margin: 0;
                font-family: 'PINGFANG_SC_SEMIBOLD', sans-serif;  
                font-weight: 600;
                font-size: 28rpx;
                color: #222222;
                line-height: 36rpx;
                text-align: left;
                font-style: normal;
                text-transform: none;
            }
        } 
        .goods:nth-child(3n-1) {
            margin-right: 20rpx;
        }
        .goods:nth-child(3n-2) {
            margin-right: 20rpx;
        }
    }
}
.img_sty{
	width: 80px;
	height: 80px;
	border-radius: 15rpx !important;
}
</style>
